package com.jd.dlc.limit;

import com.jd.dlc.autoconfigure.DlcProperties;
import com.jd.dlc.domain.LimiterRule;
import com.jd.dlc.spring.SpringUtils;
import com.jd.jim.cli.Cluster;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

import static com.jd.dlc.constant.DlcConstant.JIMDB_CLIENT_DEFAULT_NAME;

/**
 * @ClassName: BaseLimiterAbstract
 * @Description:
 * @Author: MengXiangXin
 * @Date: 2022/5/10 2:34 PM
 */

public abstract class AbsLimiter implements Limiter {

    String PREFIX = "limit_";


    public DlcProperties dlcProperties = (DlcProperties) SpringUtils.getBean("dlcProperties");

    public String getKey(String type, String arg) {
        return PREFIX + type + arg;
    }

    @Override
    public boolean refreshLimiter(LimiterRule limiterRule) {
        return doRefreshLimiter(limiterRule);
    }

    abstract boolean doRefreshLimiter(LimiterRule limiterRule);
}
